<%
layout("/layouts/platform.html"){
%>
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/chain/copyright" data-pjax><i class="ti-angle-left"></i> 返回</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/chain/copyright/addDo" method="post">
                <div class="row mb10">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label for="code" class="col-sm-2 control-label">版权号</label>
                            <div class="col-sm-8">
                            <input type="text" id="code" class="form-control" name="code" data-parsley-required="true" placeholder="版权号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="owner" class="col-sm-2 control-label">版权人</label>
                            <div class="col-sm-8">
                            <input type="text" id="owner" class="form-control" name="owner" data-parsley-required="true" placeholder="版权人">
                            </div>
                        </div>
                        <!--<div class="form-group">
                            <label for="registerTime" class="col-sm-2 control-label">注册时间</label>
                            <div class="col-sm-8">
                            <input type="text" id="registerTime" class="form-control" name="registerTime" placeholder="注册时间">
                            </div>
                        </div>-->
                        <div class="form-group">
                            <label for="indate" class="col-sm-2 control-label">有效期</label>
                            <div class="col-sm-8">
                            <input type="text" class="datetimepicker"  id="indate" class="form-control" name="indate" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="fingerPrint" class="col-sm-2 control-label">上传资源文件</label>
                            <div class="col-sm-8">
                                <div id="queue"></div>
                                <div>
                                    <input id="file_upload" name="file_upload" type="file" multiple="false">
                                </div>
                                <div id="img" >
                                </div>
                                <input type="hidden" id="fingerPrint" name="fingerPrint" value="" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="introductions" class="col-sm-2 control-label">版权说明</label>
                            <div class="col-sm-8">
                            <input type="text" id="introductions" class="form-control" name="introductions" data-parsley-required="true" placeholder="版权说明">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="auditUnit" class="col-sm-2 control-label">审核单位</label>
                            <div class="col-sm-8">
                            <input type="text" id="auditUnit" class="form-control" name="auditUnit" data-parsley-required="true" placeholder="审核单位">
                            </div>
                        </div>
                        <!--<div class="form-group">-->
                            <!--<label for="blockChainTransactionCode" class="col-sm-2 control-label">区块链交易号</label>-->
                            <!--<div class="col-sm-8">-->
                            <!--<input type="text" id="blockChainTransactionCode" class="form-control" name="blockChainTransactionCode" data-parsley-required="true" placeholder="区块链交易号">-->
                            <!--</div>-->
                        <!--</div>-->
                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
                        </div>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>
<script language="JavaScript">
    function clearFile() {
        $("#img").html("");
        $("#queue").html("");
        $("#fingerPrint").val("");
    }
    $(document).ready(function () {
        $('#file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择资源文件',
            'fileType': 'image/jpg,image/jpeg,image/png',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    console.log(data);
                    $("#img").html("指纹文件："+data.msg);
                    $("#fingerPrint").val(data.msg);
                } else {
                    clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
                clearFile();
            },
            'onClearQueue': function (queue) {
                clearFile();
            },
            'onCancel': function () {
                clearFile();
            }
        });
        $('#addForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    clearFile();
                    form.resetForm();
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
        initDatepickle()
    });

function initDatepickle() {
       $('.datetimepicker').datetimepicker({
        minView: "month",//设置只显示到月份
        format: 'yyyy-mm-dd',//显示格式
        todayBtn: true,
        language:"zh-CN",
        autoclose: true,
        startDate: new Date(),  //以前的日期不能点
        bootcssVer:3  //小箭头
        });
    }

</script>
<%}%>


